﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<JSC.Portal.Entities.PortalPage>" %>
<asp:Content ID="Head1" ContentPlaceHolderID="Head" runat="server">
    <% this.Title = JSC.Portal.Web.App.Resources.Msg.PageManagement;  %>
    <link rel="stylesheet" href="<%= Url.Asset("jquery.treeview.css").Replace("&", "&amp;") %>" type="text/css" media="screen" />
    <script type="text/javascript" src="<%= Url.Asset("jquery.treeview").Replace("&", "&amp;") %>"></script>
    <script type="text/javascript">
        $(function() {
            $("#ValidFrom").datepicker($.extend({}, $.datepicker.regional["nl"], { showStatus: true, showOn: "both" }));
            $("#ValidTill").datepicker($.extend({}, $.datepicker.regional["nl"], { showStatus: true, showOn: "both" }));
            $("#gridsections").flexigrid({
                buttons: [{ name: '<%= JSC.Portal.Web.App.Resources.Msg.AddSection %>', bclass: 'add', onpress: AddSection}],
                usepager: false, title: "<%= JSC.Portal.Web.App.Resources.Msg.Sections %>", useRp: false, height: 100
            });
            $("#gridpermissions").flexigrid({
                usepager: false, title: "<%= JSC.Portal.Web.App.Resources.Msg.Permissions %>", useRp: false, height: 100
            });
        });

        $(document).ready(function() {
            $("#formulier").validate(
            {
                rules:
                {
                    Name: "required",
                    Language: "required",
                    ValidFrom: "required",
                    Template: "required"
                },
                messages:
                {
                    Name: "*",
                    Language: "*",
                    ValidFrom: "*",
                    Template: "*"
                }
            });
            $("#Name").change(function() {
                var x = escape($(this).val());
                $.ajax({
                    url: '<%= Url.Action("GetFriendlyUrl", ControllerNames.PORTALPAGES_CONTROLLER, new { parentid = (ViewData.Model.Parent == null) ? (int?)null : ViewData.Model.Parent.Id }) %>',
                    type: 'POST',
                    //dataType: 'json',
                    data: 'name=' + x,
                    success: function(data) {
                        $('#suggest-friendlyurl').html('<%= ViewData.Model.PortalSite.Url %>/<%= ViewData.Model.Language %>/' + data.FriendlyUrl);
                    }
                });
            });
        });

        function AddSection() {
            window.location = '<%= Url.Action("Create", ControllerNames.SECTIONS_CONTROLLER, new { id = ViewData.Model.Id }) %>';
        }

        function Delete() {
            if (confirm('<%= JSC.Portal.Web.App.Resources.Msg.AreYouSureYouWantToDeleteThis %>')) {
                window.location = '<%= Url.Action("Delete", new { id = ViewData.Model.Id }) %>';
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<table width="100%">
    <tr>
        <td valign="top" width="350px">
            <% Html.RenderPartial("PortalPageTreeView", ViewData.Model.PortalSite); %>
         </td>
        <td valign="top">
            <form id="formulier" method="post" action="<%= Url.Action("SaveOrUpdate", new { id = ViewData.Model.Id }) %>">
                <%= Html.Hidden("parentid", ViewData.Model.Parent == null ? null : ViewData.Model.Parent.Id.ToString()) %>
                <%= Html.Hidden("siteid", ViewData.Model.PortalSite.Id) %>
                <fieldset class="contentfieldset">
                    <legend><%= JSC.Portal.Web.App.Resources.Msg.General %></legend>
                    <table border="0">
                        <% Html.RenderPartial("DescriptiveEntityEditControl"); %>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.FriendlyUrl%></td>
                            <td><span id="suggest-friendlyurl"><%= ViewData.Model.PortalSite.Url %>/<%= ViewData.Model.Language %>/<%= ViewData.Model.FriendlyURL %></span></td>
                        </tr>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.ParentPage %></td>
                            <td><%= ViewData.Model.Parent == null ? "" : ViewData.Model.Parent.Name %></td>
                        </tr>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.Language %></td>
                            <td><%= Html.DropDownListFor(model => model.Language, (SelectList)ViewData["Languages"], JSC.Portal.Web.App.Resources.Msg.PleaseMakeAChoice)%></td>
                        </tr>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.ShowInNavigation %></td>
                            <td><%= Html.CheckBoxFor(model => model.ShowInNavigation) %></td>
                        </tr>
                        <% if (ViewData.Model.CanMove()) { %>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.Position %></td>
                            <td><% Html.RenderPartial("PositionEditControl", ControllerNames.PORTALPAGES_CONTROLLER); %></td>
                        </tr>
                        <% } %>            
                        <% Html.RenderPartial("ValidEditControl"); %>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.MetaKeywords %></td>
                            <td><%= Html.TextAreaFor(model => model.MetaKeywords, 3, 100, null)%></td>
                        </tr>
                        <tr>
                            <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.MetaDescription %></td>
                            <td><%= Html.TextAreaFor(model => model.MetaDescription, 3, 100, null)%></td>
                        </tr>
                    </table>
                </fieldset>
                <fieldset class="contentfieldset">
                    <legend><%= JSC.Portal.Web.App.Resources.Msg.Template %></legend>
                    <%= Html.DropDownListFor(model => model.Template.Id, (SelectList)ViewData["Templates"], JSC.Portal.Web.App.Resources.Msg.PleaseMakeAChoice)%>
                </fieldset> 
                <% if (!ViewData.Model.IsNew) { %>
                <br />
                <table id="gridsections">
                    <thead>
                        <tr>
                            <th width="125"><%= JSC.Portal.Web.App.Resources.Msg.Action%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.Name%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.Description%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.Placeholder%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.Position%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.ValidFrom%></th>
                            <th width="100"><%= JSC.Portal.Web.App.Resources.Msg.ValidTill%></th>
                        </tr>
                    </thead>
                    <tbody>
                        <%foreach (Section s in ViewData.Model.Sections)
                          { %>
                            <tr>
                                <td><%= Html.GridLinkButton(JSC.Portal.Web.App.Resources.Msg.Edit, Url.Action("Edit", ControllerNames.SECTIONS_CONTROLLER, new { id = s.Id }))%></td>
                                <td><%= Html.Encode(s.Name)%></td>
                                <td><%= Html.Encode(s.Description)%></td>
                                <td><%= Html.Encode(s.Placeholder)%></td>
                                <td><% Html.RenderPartial("PositionEditControl", ControllerNames.SECTIONS_CONTROLLER, s); %></td>
                                <td><%= Html.Encode(s.ValidFrom)%></td>
                                <td><%= Html.Encode(s.ValidTill.HasValue ? s.ValidTill.Value.ToString("dd-MM-yyyy") : JSC.Portal.Web.App.Resources.Msg.Infinity)%></td>
                            </tr>
                        <%}%>
                    </tbody>
                </table>
                <% } %>
                <% Html.RenderPartial("PermissionsEditControl"); %>
                <%= Html.CheckBox("propagateToSections") %><label for="propagateToSections"><%= JSC.Portal.Web.App.Resources.Msg.PropagateToSections %></label><br />
                <%= Html.CheckBox("propagateToChildPages") %><label for="propagateToChildPages"><%= JSC.Portal.Web.App.Resources.Msg.PropagateToChildPages %></label><br />   
                <div class="button-bar-right">
                    <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Cancel, Url.Action("List"))%>
                    <%= Html.SeperatorRight() %>
                    <%= Html.LinkButtonRight("Design", Url.Action("Design", ControllerNames.PORTALPAGEDESIGNER_CONTROLLER, new { id = ViewData.Model.Id }))%>
                    <%= Html.SeperatorRight() %>
                    <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.CreateChildPage, Url.Action("CreateChildPage", new { id = ViewData.Model.Id }))%>
                    <%= Html.SeperatorRight() %>
                    <% if (ViewData.Model.CanDelete) { %>
                    <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Delete, "javascript:Delete()")%>
                    <% } %>
                    <%= Html.SeperatorRight() %>
                    <%= Html.SubmitButtonRight(JSC.Portal.Web.App.Resources.Msg.Save)%>                    
                </div>
                        
            </form>
        </td>
    </tr>
</table>    
</asp:Content>
    